package cn.wolfcode.crm.domain;

import cn.wolfcode.crm.util.DateUtil;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class CustomerTraceHistory extends BaseDomain{

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;

    private String traceDetails;

    private SystemdictionaryItem traceType;//包括id  title

    private Integer traceResult =3;//优 中 差 ???

    private String remark;

    private Customer customer; //包括id  name

    private Employee inputUser; //包括 id,name

    private Date inputTime;

    public String getJson()
    {
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("traceTime", DateUtil.formatDate(traceTime));
        map.put("traceDetails",traceDetails);
        map.put("traceType",traceType);
        map.put("traceResult",traceResult);
        map.put("remark",remark);
        map.put("customerId",customer.getId());
        map.put("customerName",customer.getName());
        map.put("inputUserId",inputUser.getId());
        map.put("inputUserName",inputUser.getName());
        map.put("inputTime",inputTime);
        return JSON.toJSONString(map);
    }
//??作用
    public String getTraceResultName()
    {
        String result = "";
        if(traceResult==1)
        {
            result = "差";
        }else if(traceResult==2)
        {
            result = "良";
        }else if(traceResult==3){
            result = "优";
        }
        return result;
    }

}